﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDAL.Student;
using DALFactory;
using Model.Student;

namespace BLL.Student
{
    public class BLStudent
    {

        IStudent objManage = DataAccess.Create_Student();

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="obj">实体对象</param>
        /// <returns>新插入记录的编号</returns>
        public void Insert(StudentEntity obj)
        {
            objManage.Insert(obj);
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="obj">实体对象</param>
        public void Update(StudentEntity obj)
        {
            objManage.Update(obj);
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="info_id">记录编号，多个用“,”分开</param>
        public void Delete(string info_id)
        {
            string[] arrProID = info_id.Split(',');
            foreach (string sProID in arrProID)
            {
                objManage.Delete(sProID);
            }
        }

        /// <summary>
        /// 获得单个实体
        /// </summary>
        /// <param name="info_id">记录编号</param>
        /// <returns>实体对象</returns>
        public StudentEntity GetInfo(string info_id)
        {
            return objManage.GetInfo(info_id);
        }

        /// <summary>
        /// 按指定条件获得记录数
        /// </summary>
        /// <param name="condition">查询条件</param>
        /// <returns>记录数</returns>
        public int GetCount(StudentEntity.SearchCondition condition)
        {
            return objManage.GetCount(condition);
        }

        /// <summary>
        /// 按指定条件获得查询结果
        /// </summary>
        /// <param name="startIndex">记录开始索引，从1开始。如果startIndex和endIndex都为0表示不分页</param>
        /// <param name="endIndex">结束索引</param>
        /// <param name="condition">查询条件</param>
        /// <returns>实体集</returns>
        public List<StudentEntity> GetList(int startIndex, int endIndex, StudentEntity.SearchCondition condition)
        {
            return objManage.GetList(startIndex, endIndex, condition);
        }
    }
}
